using System;
using System.Data.Entity.ModelConfiguration;
using System.Data.Common;
using System.Data.Entity;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using Dal.Entities;

namespace Dal.Mapping
{
	public class UserMap : EntityTypeConfiguration<User>
	{
		public UserMap()
		{
			// Primary Key
			this.HasKey(t => t.ID);

			// Properties
			this.Property(t => t.UserName)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.Password)
				.IsRequired()
				.HasMaxLength(50);
				
			this.Property(t => t.Tel)
				.HasMaxLength(50);
				
			this.Property(t => t.ChargeMan)
				.HasMaxLength(50);
				
			// Table & Column Mappings
			this.ToTable("User");
			this.Property(t => t.ID).HasColumnName("ID");
			this.Property(t => t.UserName).HasColumnName("UserName");
			this.Property(t => t.Password).HasColumnName("Password");
			this.Property(t => t.Tel).HasColumnName("Tel");
			this.Property(t => t.ChargeMan).HasColumnName("ChargeMan");
			this.Property(t => t.RegionID).HasColumnName("RegionID");
			this.Property(t => t.Role).HasColumnName("Role");
		}
	}
}

